#ifndef ACCOUNT_H
#define ACCOUNT_H

#include <vector>

struct HistBalance
{
    int m_orderNo;
    int m_id;
    double m_balance;
};

class AccountListener
{
public:
    virtual void onAccountChanged() = 0;
};

class Account
{
public:
    static Account* inst();
    inline void setFee(double fee) { m_fee = fee; }
    void setBalance(int orderNo, double balance);
    double getAccountFloating();
    double getAccountEquity();
    double getAccountBalance();
    double getAccountFee();
    const std::vector<HistBalance>& getHistBalance() const { return m_vecHistBalance; }
    void clearHistBalance();
    inline double getMaxBalance() const { return m_maxBalance; }
    inline double getMinBalance() const { return m_minBalance; }
    void addListener(AccountListener *listener);
    void accountChanged();

private:

    Account();
    double m_originBalance;
    double m_balance;
    double m_fee;
    double m_maxBalance;
    double m_minBalance;
    std::vector<HistBalance> m_vecHistBalance;
    std::vector<AccountListener*> m_vecListener;
    static Account *s_inst;
};

#endif